/*
ID:manyous1
PROG:castle
LANG:C++
*/
#define loops for(i=1;i<=n;i++)    for(j=1;j<=m;j++)
#define loops2 for(j=1;j<=m;j++)   for(i=n;i>=1;i--)
#include<stdio.h>
#include<algorithm>  
using namespace std;   
int n,t,m,ga[52][52],room[52*52],i,j,maxi,maxj,maxr;//wall:  2
char maxw;                                          //     1 + 3
bool wall[52][52][5];                               //       4
void deal(int w,int i,int j){
     if(w&1)(wall[i][j][1]=true);
     if(w&2)(wall[i][j][2]=true);
     if(w&4)(wall[i][j][3]=true);
     if(w&8)(wall[i][j][4]=true);
}
bool ff(int i,int j){
     bool *a=wall[i][j];
     if(ga[i][j]!=-1)return false;
     ga[i][j]=t;
     room[t]++;
     if(!a[1])ff(i,j-1);
     if(!a[2])ff(i-1,j);
     if(!a[3])ff(i,j+1);
     if(!a[4])ff(i+1,j);
     return true;
}
int main(){
    freopen("castle.in","r",stdin);
    freopen("castle.out","w",stdout);
    scanf("%d %d",&m,&n);
    loops{
                      scanf("%d",&t);
                      deal(t,i,j);
                      ga[i][j]=-1;
                      }
    t=0;
    loops if(ff(i,j))t++;
    printf("%d\n",t);
    printf("%d\n",*max_element(room,room+t));
    loops2{
               if(ga[i][j]!=ga[i-1][j]&&i-1!=0)
                            t=room[ga[i][j]]+room[ga[i-1][j]];
               if(t>maxr){
                         maxi=i;maxj=j;maxw='N';maxr=t;
                         }
               if(ga[i][j]!=ga[i][j+1]&&j+1<=m)
                            t=room[ga[i][j]]+room[ga[i][j+1]];
               if(t>maxr){
                         maxi=i;maxj=j;maxw='E';maxr=t;
                         }             
           }           
    printf("%d\n%d %d %c\n",maxr,maxi,maxj,maxw);
}
